package com.example.demo.mapper.entity;

import cn.hutool.core.annotation.Alias;
import com.opencsv.bean.CsvBindByName;
import lombok.Data;

import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
import java.util.Random;

@Data
@Table(name="student")
public class Student {
    @Id
    private int id;

    @Alias("学号")
    @CsvBindByName(column = "学号")
    private String number;

    @Alias("姓名")
    @CsvBindByName(column = "姓名")
    private String name;

    @Alias("性别")
    @CsvBindByName(column = "性别")
    private int gender;

    @Alias("生日")
    @CsvBindByName(column = "生日")
    private String birthday;

    @Alias("身份证号码")
    @CsvBindByName(column = "身份证号码")
    private String identityCard;

    @Alias("籍贯")
    @CsvBindByName(column = "籍贯")
    private int nativePlace;

    @Alias("民族")
    @CsvBindByName(column = "民族")
    private String nationality;

    @Alias("政治面貌")
    @CsvBindByName(column = "政治面貌")
    private int politicsStatus;

    @Alias("手机号码")
    @CsvBindByName(column = "手机号码")
    private String phone;

    @Alias("邮箱")
    @CsvBindByName(column = "邮箱")
    private String email;


    @Alias("学院id")
    @CsvBindByName(column = "学院id")
    private int collegeId;

    @Alias("专业id")
    @CsvBindByName(column = "专业id")
    private int majorId;

    @Alias("班级")
    @CsvBindByName(column = "班级")
    private String clazz;

    @Alias("宿舍楼")
    @CsvBindByName(column = "宿舍楼")
    private String dormitory;

    @Alias("房间号")
    @CsvBindByName(column = "房间号")
    private String roomNumber;

    @Alias("床位号")
    @CsvBindByName(column = "床位号")
    private String bedNumber;

    @Alias("紧急联系人")
    @CsvBindByName(column = "紧急联系人")
    private String contact;

    @Alias("紧急联系人联系方式")
    @CsvBindByName(column = "紧急联系人联系方式")
    private String contactPhone;

    @Alias("头像")
    @CsvBindByName(column = "头像")
    private String avatar;

    @Alias("密码")
    @CsvBindByName(column = "密码")
    private String password;

    @Alias("高考成绩")
    @CsvBindByName(column = "高考成绩")
    private float score;

    @Alias("状态")
    @CsvBindByName(column = "状态")
    private int state;

    @Alias("免冠照片")
    @CsvBindByName(column = "免冠照片")
    private String bareheadedPhoto;

    @Alias("录取通知书编号")
    @CsvBindByName(column = "录取通知书编号")
    private String enrollmentId;

    private String phoneCode;

    private String emailCode;

    private String nickname;

    private Date createTime;

    public String getPhoneCode() {
        return phoneCode;
    }

    public String getEmailCode() {
        return emailCode;
    }

    public void setNickname() {
        // 创建一个Random对象用于生成随机数
        Random random = new Random();
        // 确定随机数字的长度为6
        int randomNumberLength = 6;
        // 创建一个StringBuilder来构建昵称
        StringBuilder nicknameBuilder = new StringBuilder("U_");
        // 向昵称中添加随机数字
        for (int i = 0; i < randomNumberLength; i++) {
            // 生成一个随机数字字符（0-9）
            int randomNumber = random.nextInt(10);
            // 将随机数字字符添加到昵称中
            nicknameBuilder.append(randomNumber);
        }
        // 将StringBuilder转换为String并返回
        // return nicknameBuilder.toString();
        this.nickname = nicknameBuilder.toString();
    }

}
